home *** CD-ROM | disk | FTP | other *** search
/ Amiga Mag HDD Backup / Amiga Mag HDD Backup.zip / Amiga Mag HDD Backup / Alexander.img.bin / Alexander.img / 9.12 / Frawley⁄Digital FX14 / DISFX.ColorCorrect101.ascii < prev    next >
Text File  |  1983-05-04  |  14KB  |  168 lines

  1. digital image special fx
  2.  
  3. COLOR CORRECTION 101
  4. Exploring 1-To-1 Pixel Transformations
  5.  
  6. by William Frawley
  7.  
  8.  
  9.     Since coverage of basic video color correction is scarce among monthly computer-oriented 
  10. periodicals, especially for Amiga users, it's time we learn what all those Balancing functions like 
  11. Bright, Contrast and Gamma actually do and what related terms such as Dynamic Range, 
  12. Posterization and Histogram really mean. Alas, welcome to Color Correction 101. Here we'll 
  13. uncover the theory behind 1-To-1 pixel transformations and illustrate their effect on a sample 
  14. image. We'll also see how most of the digital image manipulation tools used to perform these 
  15. functions closely resemble in operation many photographic darkroom techniques.
  16.     From print media via desktop publishing to video production, fine tuning the color content 
  17. of a photograph or a video signal is a crucial step taken to ensure the most accurate color 
  18. reproduction possible for the viewer's digestion, and ultimately, their perception. For example, in  
  19. video production, consider the case where two different scenes are shot with two different types of 
  20. video camcorders. In the final edit, color correction of the two disparate video signals is necessary 
  21. for an inconspicuous, seamless transition between the two scenes. This is an example of a more 
  22. advanced application of color transformation. However, as we shall see, pixel transformations can 
  23. be as simple as adding contrast or brightness, producing a negative or even reducing the amount 
  24. of colors in an image, a process called quantization or posterization. But before we demystify 
  25. these processes, here's what you'll need to get started.
  26.  
  27. Prerequisites
  28.     Okay, if you're reading this column, odds are you have some kind of image processing 
  29. software. For this series, we'll generally be using ADPro for most of the basic operations and 
  30. ImageFX for more of the special functions, but every concept and even most functions and 
  31. operators easily apply to other packages as well -- like OpalPaint and ImageMaster R/T. We will 
  32. try to occasionally enlist these others when we examine next month some of the more advanced 
  33. operations exclusive to a particular program. Until then, all interested graphics users should 
  34. follow along because this article deals with the general theory of pixel transformations -- the 
  35. underlying principles of enhancing an image through color correction.
  36.  
  37. RGB and HSV Color Systems
  38.     Before we begin, perhaps I should point out that our dealings with color and methods of 
  39. correction will be confined to digital video and the world of pixels. At this point, I would hope 
  40. that you already know what pixels are. If not, remember that pixel is an abbreviation for picture 
  41. element, the individual `dots' or units that constitute a bitmap image.
  42.     When dealing with video or images in the digital realm, recall that the systems used for 
  43. color manipulation can consist of either the RGB (Red Green Blue), HSV (Hue Saturation 
  44. Value) or in more high-end broadcast situations, the YUV (Luminance Y/R-Y/B-Y) color system. 
  45. As the space allotted here will not allow for a full explanation of the complexity of video signals, 
  46. suffice it to say that these color models were designed with respect to how colors are actually 
  47. reproduced and what devices they are output to. That is, the color video signal is output to a 
  48. monitor, which consists of separate red, green and blue color guns. Therefore, the most 
  49. appropriate `color space' to work in would be the RGB system or the more general and flexible 
  50. HSV color system. Obviously, since we are dealing with light beams as the final output, both 
  51. systems mentioned subscribe to the additive theory of color reproduction, in contrast to the 
  52. CMYK system of color separation for print media, whose output is based upon the subtractive 
  53. theory of color. Consequently, the mechanics of the output process dictate the best method or 
  54. system to deal with the individual components of color, be it light or the more tangible pigments. 
  55. With that exposition in mind, let's now expose the nature of 1-to-1 pixel transformations.
  56.  
  57. 1-To-1 Pixel Transformations
  58.     Simply put, these types of 1-to-1 transformations are such that the value of a pixel's output 
  59. is strictly a function of the input pixel's value. In other words, the new value depends only on the 
  60. original value. Written in mathematical notation, the relationship looks like this:  y=f(x). On the 
  61. contrary, there exist certain processes like convolution and dithering which are not simple 1-to1 
  62. relationships but rely on a matrix of pixels. Convolutions base their output on a neighborhood of 
  63. surrounding input pixels, and similarly, dithering also depends on values of nearby pixels and 
  64. their position in the bitmap plane.
  65.     Because of the simplicity of their nature, we can easily show these 1-to-1 transforms graphed 
  66. two-dimensionally, where the horizontal axis represents discrete input values from 0-255 and the 
  67. vertical axis represents the discrete output values from 0-255. Despite the fact that our sample 
  68. image is color, just think of the function graphs as representing the input-output relationships of 
  69. a monochrome grayscale image, or just one component of the RGB combination. Let's now take a 
  70. look at a variety of 1-to-1 transformation algorithms and their effect on our sample image.
  71.  
  72. Example Transformations
  73.     NULL:  For completeness, the simplest transform is obviously a null transform, where the 
  74. output is exactly equal to the input. In mathematical notation we write, f(x)=x. In this case, noth-
  75. ing changes. The new pixel has the same value as the old pixel. Not very exciting, but it demon-
  76. strates that even the simplest of functions provide a basic understanding of important relation-
  77. ships between input and output values. Refer to Figure 1A which shows the graphical repre-
  78. sentation of the Null transformation. Figure 1B illustrates a good example image to begin our 
  79. demonstration because it provides an even distribution bandwidth of luminance values to work 
  80. with, as shown in a histogram for this image (see next month's article for a discussion on the im-
  81. portance of histograms).
  82.     NEGATIVE:  Also known as Photo-Inversion, this transform reverses the output luminance 
  83. values, similar to a photographic negative. Imagine a horizontal line extending midway from the 
  84. vertical axis. Using this imaginary line as an axis of symmetry, flip the Null function about this 
  85. axis and you end up with the Negative function. Essentially, any dark pixels become bright and 
  86. any bright pixels become dark. Median value pixels don't change that much, and specifically, if a 
  87. pixel had the luminance value of 128 to begin with, it would remain 128 after the transformation. 
  88. This value acts as the pivot point for the function inversion, remembering that there are 256 pos-
  89. sible luminance values for 8-bit images or for each RGB component of 24-bit images. .This func-
  90. tion could be written as, f(x)=256-x. See Figure 2A for a graphical representation of the trans-
  91. formation. Figure 2B shows the effect of using ADPro's Negative operator on our sample image.
  92.     BRIGHTNESS:  This type of adjustment or transformation affects the brightness of an im-
  93. age. It does so by uniformly shifting the color map upwards or downwards by a certain Offset 
  94. value. Therefore, all input values get shifted by the exact same amount, no matter where they lie 
  95. on the horizontal axis (input value axis). Notice that any range of input intensities also produces 
  96. the exact range of output intensities, only shifted upwards or downwards by the Offset value. The 
  97. slope of the curve remains the same. This transform can be written as f(x)=Offset+x. The in-
  98. creased brightness function is illustrated in Figure 3A. The result shows that all color values get 
  99. boosted by some Offset amount, thus making the image brighter. The disadvantage of this type of 
  100. transform is demonstrated in the extreme luminance values. Note that there are no longer any 
  101. extreme dark values, and any lighter values above a certain point get clipped, or all receive the 
  102. same maximum value of 255. This eliminates any detail in the lighter portion of the image. Just 
  103. the opposite occurs with decreased brightness. Figures 3B and 3C show the result of increased 
  104. and decreased brightness, respectively. Note that the function is still linear and contains the same 
  105. slope as before which remains constant. Some of these factors will change in the following trans-
  106. forms.
  107.     CONTRAST:  This popular 1-to-1 transformation is similar in some respects to both the 
  108. Negative and the Brightness adjustments. Like the Negative transform, this color map is pivoted 
  109. about the center point, thus changing the slope of the function. Unlike the Negative transform 
  110. however, the slope still remains positive so there is still a `normal' relationship between the input 
  111. values and the output values. A larger slope means increased contrast, and a more horizontal 
  112. slope represents decreased contrast. Additionally, like the Brightness transform, adjusting the con-
  113. trast or slope of the `curve' also produces undesirable clipping at the extreme ends of the input 
  114. intensities. This transform's strength, however, lies in the fact that for any given range of input 
  115. values, except for the clipped regions, the corresponding range of output values have been ex-
  116. panded, thus adding increased detail in those areas. Figure 4A shows this relationship with the 
  117. shaded areas representing arbitrary value ranges selected for examination. The slightly more com-
  118. plex, but still linear, mathematical formula can be written as f(x)=0 when x<=low, 
  119. f(x)=(x-low)/(high-low) when low<x<high, and f(x)=255 when x>=high. The effects of in-
  120. creased and decreased contrast are illustrated in Figures 4B and 4C, respectively.
  121.     GAMMA:  Containing characteristics of both Brightness and Contrast adjustments, this 
  122. transform adjusts the overall brightness of an image at the same time affecting the contrast in a 
  123. non-linear fashion. It is non-linear because the slope of the curve, and here it is actually curvilin-
  124. ear, is constantly changing. Unlike the Brightness function however, the advantage here is that 
  125. because of the non-linear nature of the curve, the extreme highs and lows avoid clipping, thus 
  126. preserving detail in these regions. Additionally, because there is a perpetually changing slope, in-
  127. put values lying in a certain range produce either expanded or contracted output values, depend-
  128. ing upon what part of the curve is considered. Consequently, different regions of the curve pro-
  129. duce either increased or decreased contrast. Only at one point, usually the center, does the slope 
  130. remain equal to the original. This function is written as f(x)=x^gamma. When gamma<1, the curve 
  131. bows upward, producing increased brightness. When gamma>1, the curve bows downward, de-
  132. creasing the overall brightness of the image. A gamma value equal to 1 produces a null transform. 
  133. Figure 5A illustrates a gamma correction transform with a factor less than 1, thus increasing the 
  134. overall brightness of the input signal.
  135.     The nature of the Gamma transform closely parallels certain real-world conditions such as 
  136. the brightness control response of CRT's and certain variations in darkroom exposure param-
  137. eters. This form of adjustment curve takes into account these types of non-linear output responses 
  138. to linear input ranges. For example, output devices like your monitor are usually considered to 
  139. have a gamma factor of 2.2 producing a downward-bowed curve. This results in the darkening of 
  140. the video output. To compensate for this darker, non-linear response, we brighten the image by 
  141. applying a reciprocal gamma curve to the output signal. In this case, we would use a gamma cor-
  142. rection curve with a gamma factor of .45, the reciprocal of 2.2. This would then bring the dis-
  143. played output within normal viewing parameters. Figures 5B and 5C show the effects of both 
  144. increased and decreased gamma corrections, respectively.
  145.     POSTERIZATION:  Also known as and a more accurately termed transform called quan-
  146. tization, this adjustment has the effect of reducing the output to a distinct number of values by 
  147. `slicing' the input intensities into a discrete number of ranges. Each member of a range is then 
  148. assigned the same output intensity. This creates a stair-step transform function curve as shown in 
  149. Figure 6A. Creating a monochrome image is an extreme case of quantization, resulting in all 
  150. input values being mapped to a luminosity of either 0 or 255. In this case, the function is written 
  151. as f(x)=0 when 0<=x<=128(?) and f(x)=255 when 128(?)<=x<=255. In this case, the value of 
  152. 128 is arbitrary. Any cut-off point could be chosen. However, most image processors with a pos-
  153. terization operator allow you to choose the number or complexity of output levels. The example 
  154. in Figure 6B was created with ImageFX's Posterize... tool located in the Color Effects menu 
  155. where a level of 5 out of 16 was used. In a sense, every time you render a full-color image to a 
  156. native Amiga display format, a reduced output value color map in the same vein as a posteriza-
  157. tion transform is created for the graphics hardware to display the image. With normal rendering 
  158. though, the render algorithm picks the optimum colors for the best possible display output.
  159.  
  160. Next Time
  161.     Well, that about covers the basic color transformations. Hopefully, now that you understand 
  162. the operation of them, you'll be apt to use them more frequently. From enhancing poorly scanned 
  163. clipart to spicing up your latest video work with special effects, 1-to-1 pixel transformations can 
  164. provide countless ways to easily but powerfully process images. Believe me, we've just scratched 
  165. the surface of color transformations. Next month, we'll continue our look at some custom 1-to-1 
  166. transformations, specialized transformation operators like ADPro's Intensity Range, including the 
  167. use and meaning of histograms, and much more. Until then, experiment. It's a blast!
  168.